-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(sbb-chip-group): initial implementation #3382
base: main
Are you sure you want to change the base?
Conversation
# Conflicts: # src/elements/autocomplete/autocomplete-base-element.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looks good, some detail to fix
@@ -30,6 +30,11 @@ import style from './autocomplete-base-element.scss?lit&inline'; | |||
*/ | |||
const ariaRoleOnHost = isSafari; | |||
|
|||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we have an events
property?
let input: HTMLInputElement; | ||
let focusStep: HTMLInputElement; | ||
|
||
describe('basic interactions', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
describe('basic interactions', () => { | |
describe('sbb-chip-group', () => { |
possibly adding a nested described with 'basic interaction'
}); | ||
}); | ||
|
||
describe.only('with autocomplete', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
describe.only('with autocomplete', () => { | |
describe('with autocomplete', () => { |
}; | ||
|
||
// TODO | ||
export const WithAutoComplete: StoryObj = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MEMO: remove todo
export const WithAutoComplete: StoryObj = { | |
export const WithAutocomplete: StoryObj = { |
import style from './chip-group.scss?lit&inline'; | ||
|
||
/** | ||
* Describe the purpose of the component with a single short sentence. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace this placeholder text
const toRemove = [...oldValue]; | ||
for (const c of value) { | ||
if (toRemove.includes(c)) { | ||
toRemove.splice(toRemove.indexOf(c), 1); | ||
} | ||
} | ||
toRemove.forEach((value) => | ||
this._chipElements() | ||
.find((c) => c.value === value) | ||
?.remove(), | ||
); | ||
|
||
// Subtract from the new 'value' what was already present | ||
// The result are the new chips to add (handle duplicates) | ||
const toAdd = [...value]; | ||
for (const c of oldValue) { | ||
if (toAdd.includes(c)) { | ||
toAdd.splice(toAdd.indexOf(c), 1); | ||
} | ||
} | ||
toAdd.forEach((c) => this._createChipElement(c)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: could the usage of Set and Set's method (difference, insersection, etc) improve this code?
@@ -0,0 +1,52 @@ | |||
import { html } from 'lit'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove placeholder comments from this file
|
||
## Accessibility | ||
|
||
The `sbb-chip-group` follows the `grid` pattern; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
infos are missing, or the ; must be replaced with .
The `sbb-chip-group` has a `negative` variant. If within a `sbb-form-field`, the properties automatically sync. | ||
|
||
```html | ||
<sbb-form-field negative> | ||
<sbb-chip-group name="field-name"> | ||
<sbb-chip value="Value 1"></sbb-chip> | ||
... | ||
<input /> | ||
</sbb-chip-group> | ||
</sbb-form-field> | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can go in ## Style maybe?
import { i18nChipDelete } from '@sbb-esta/lyne-elements/core/i18n/i18n'; | ||
|
||
/** | ||
* Describe the purpose of the component with a single short sentence. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this placeholder text
Open topics
Preflight Checklist
Issue
This PR Closes #2761
Pull request checklist
Please check if your PR fulfills the following requirements:
See Review Guidelines for more information what is checked during review process.
Changes
Changes in this pull request:
sbb-chip-group
sbb-chip
Browsers
I tested the build on the following browsers:
Screen readers
I tested the build on the following browsers:
Pull request type
Please check the type of change your PR introduces:
Does this introduce a breaking change?
Other information